﻿@using EC.Entity.Enum;
@{
    Layout = "~/Views/Shared/_Dialog.cshtml";
}
@model EC.Entity.Response.Menu.MenuResponse
    <section class="container-fluid" style="background-color: white;">


        <form class="form-horizontal m15_t" id="form">
            <div class="tab-content">
                <input type="hidden" id="Id" name="Id" value="@(Model.Id)">
                <input type="hidden" id="ParentId" name="ParentId" value="0">
                <div class="tab-pane fade in active" id="home">
                    <div class="form-group">
                        <label class="wd100 control-label"><span class="WdateFmtErr">*</span>名称：</label>
                        <div class="wd400 m15_l">
                            <input class="form-control" type="text" name="name" maxlength="40" value="@(Model.Name)" autocomplete="off" placeholder="长度必须介于 2 和 40 之间">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="wd100 control-label"><span class="WdateFmtErr">*</span>导航显示：</label>
                        <div class="wd400 m15_l">
                            <label class="m10_r">
                                <input type="radio" name="isNav" value="@((int)IsNav.显示)" @(Model.IsNav.Equals((int)IsNav.显示) ? "checked" : "")> 显示
                            </label>
                            <label>
                                <input type="radio" name="isNav" value="@((int)IsNav.不显示)" @(Model.IsNav.Equals((int)IsNav.不显示) ? "checked" : "")> 不显示
                            </label>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="wd100 control-label">链接地址：</label>
                        <div class="wd400 m15_l">
                            <input class="form-control" type="text" name="url" maxlength="120" value="@(Model.Url)" autocomplete="off" placeholder="">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="wd100 control-label"><span class="WdateFmtErr">*</span>排序：</label>
                        <div class="wd400 m15_l">
                            <input class="form-control" type="text" name="displayOrder" maxlength="2" value="@(Model.DisplayOrder.Equals(0)?"":Model.DisplayOrder.ToString())" autocomplete="off" placeholder="排序只能为整数">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="wd100 control-label"><span class="WdateFmtErr">*</span>状态：</label>
                        <div class="wd400 m15_l">
                            <label class="m10_r">
                                <input type="radio" name="status" value="@((int)MenuStatus.启用)" @(Model.Status.Equals((int)MenuStatus.启用) ? "checked" : "")> 启用
                            </label>
                            <label>
                                <input type="radio" name="status" value="@((int)MenuStatus.禁用)" @(Model.Status.Equals((int)MenuStatus.禁用) ? "checked" : "")> 禁用
                            </label>
                        </div>
                    </div>
                </div>
                <!--菜单-->
                <div class="tab-pane fade" id="permissions">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <button type="button" class="btn btn-success" data-href="@Url.Action("MenuPermission", "Auth")" data-title="权限选择" data-width="600" data-height="500" onclick="return view(this)">&nbsp;<span class="glyphicon glyphicon-plus-sign"></span>添加</button>
                        </div>
                        <table class="table table-bordered table-hover privileges">
                            <thead>
                                <tr>
                                    <th class="t_l">权限名称</th>
                                    <th class="t_l wd120">权限代码</th>
                                    <th class="t_l wd150">备注</th>
                                    <th class="t_c wd75">操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr class="noRecord">
                                    <td colspan="4">暂无记录！</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>

            </div>
        </form>

    </section>
@section footerScript{
    <script type="text/javascript">

        function save() {

            var cover = FlashPay.UI.Mask({
                obj: $("body"),
                opacity: 0.5
            });

            var data = $("#form").serializeJSON();
            //状态
            //data.status = $("input[name='status'][checked]").val();

            FlashPay.Util.Ajax({
                type: "POST",
                url: "/Auth/SaveMenu",
                data: data,
                success: function (res) {
                    if (res.success) {
                        cover.Remove();
                        FlashPay.UI.DialogOpener().Tip_success("操作成功！");
                        FlashPay.UI.DialogOpener().doSearch();
                        FlashPay.UI.CloseDialog();
                    } else {
                        cover.Remove();
                        FlashPay.UI.Tip_short_warning("操作失败！" + res.message);
                    }
                },
                error: function (json) {
                    cover.Remove();
                    FlashPay.UI.Tip_warning("操作失败！请查看网络，请重试。");
                }
            });

        }
    </script>
}